package pers.jphoebe.quartz.entity.juhe;

import com.fasterxml.jackson.annotation.JsonFormat;
import pers.jphoebe.quartz.utils.BigDecimalUtil;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;

/**
 * Created by 蒋时华 on 2017/10/31.
 */
public class GoldData implements Serializable {

    /**
     * 品种
     */
    private String variety;
    /**
     * 最新价
     */
    private String latestpri;
    /**
     * 开盘价
     */
    private String openpri;
    /**
     * 最高价
     */
    private String maxpri;
    /**
     * 最低价
     */
    private String minpri;
    /**
     * 涨跌幅
     */
    private String limit;
    /**
     * 昨收价
     */
    private String yespri;
    /**
     * 总成交量
     */
    private String totalvol;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Timestamp time;

    /**
     * 1g白银价格，扩展
     */
    private Double AgByg;


    public Double getAgByg() {
        return AgByg;
    }

    public void setAgByg(String latestpri) {
        double f = Double.valueOf(latestpri)/1000;
        BigDecimal b = new BigDecimal(f);
        double f1 = BigDecimalUtil.scaleHalfUp(b).doubleValue();
        AgByg = f1;
    }

    public String getVariety() {
        return variety;
    }

    public void setVariety(String variety) {
        this.variety = variety;
    }

    public String getLatestpri() {
        return latestpri;
    }

    public void setLatestpri(String latestpri) {
        if(VarietyType.AgTD.equals(this.getVariety())){
            this.setAgByg(latestpri);
        }
        this.latestpri = latestpri;
    }

    public String getOpenpri() {
        return openpri;
    }

    public void setOpenpri(String openpri) {
        this.openpri = openpri;
    }

    public String getMaxpri() {
        return maxpri;
    }

    public void setMaxpri(String maxpri) {
        this.maxpri = maxpri;
    }

    public String getMinpri() {
        return minpri;
    }

    public void setMinpri(String minpri) {
        this.minpri = minpri;
    }

    public String getLimit() {
        return limit;
    }

    public void setLimit(String limit) {
        this.limit = limit;
    }

    public String getYespri() {
        return yespri;
    }

    public void setYespri(String yespri) {
        this.yespri = yespri;
    }

    public String getTotalvol() {
        return totalvol;
    }

    public void setTotalvol(String totalvol) {
        this.totalvol = totalvol;
    }

    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }
}
